﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Common;
using MySoftWare.DataAccess;
using System.Data;
using MySoftWare.Component.Tools;

namespace MySoftWare.DataCommon
{
    /// <summary>
    /// added by lqm 2013.06.01
    /// </summary>
    public class LoginAccessor
    {
        /// <summary>
        /// 登录验证
        /// </summary>
        private const string Sql_Login = @"select count(*) from Sys_User where UserAccount=@UserAccount and UserPassword=@UserPassword";
        public static bool Login(string UserAccount, string UserPassword)
        {
            string SecretPass =UserPassword.Encode();   ///对密码进行加密
            DbParameter[] Params = { 
                                        DBHelper.MakeInParam("@UserAccount", DbType.String,UserAccount),
                                        DBHelper.MakeInParam("@UserPassword", DbType.String,SecretPass),
                                   };
            int count=(int)DBHelper.ExecuteScalar(CommandType.Text, Sql_Login,Params);
            return (count > 0);
        }
    }
}
